/*
Copyright (c) 2011 Vratislav Cermak (vratacermak@gmail.com)
 
This file is part of TeachMe Project. See http://code.google.com/p/teach-me for more information.
 
TeachMe is an open source project. Using of TeachMe is free of charge.
It is distributed under GNU General Public License version 3 (GPLv3).
GPLv3 can be found at http://www.gnu.org/licenses/gpl.html.
 
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

using System;
using System.Collections.Generic;
using System.Text;

namespace TeachMe.Application
{
    public class Encodings
    {
        private static readonly string[] Suported =
        {
            "WINDOWS-1250",
            "WINDOWS-1251",
            "WINDOWS-1252",
            "WINDOWS-1253",
            "WINDOWS-1254",
            "WINDOWS-1255",
            "WINDOWS-1256",
            "WINDOWS-1257",
            "WINDOWS-1258",
            "ISO-8859-1",
            "ISO-8859-2",
            "ISO-8859-3",
            "ISO-8859-4",
            "ISO-8859-5",
            "ISO-8859-6",
            "ISO-8859-7",
            "ISO-8859-8",
            "ISO-8859-8-I",
            "ISO-8859-9",
            "ISO-8859-10",
            "ISO-8859-13",
            "ISO-8859-14",
            "ISO-8859-15",
            "ISO-8859-16",
            "UTF-7",
            "UTF-8",
            "UTF-16",
        };

        public static IEnumerable<Encoding> Items
        {
            get
            {
                foreach (string encoding in Suported)
                {
                    Encoding e;
                    try
                    {
                        e = Encoding.GetEncoding(encoding);
                    }
                    catch (ArgumentException)
                    {
                        continue;
                    }
                    yield return e;
                }
            }
        }
    }
}